package ch.bfh.parallaxis.intents;

import java.util.GregorianCalendar;
/**
 * Die wichtigsten Informationen zum Integrator werden geliefert.
 * Dies ist die Antwort auf: IntegratorCheckActualStateIntent
 */
public class IntegratorActualStateIntent extends ParallaXisBaseIntent{
	private int bufferSize;
	private double minPercentalBufferContent;
	private double actualPercentalBufferContent;
	private boolean running;
	private double precision;
	private double maxNoiseError;
	
	public IntegratorActualStateIntent(Object sender, int bufferSize, double minPercentalContent, double actualPercentalContent, 
			double precision, double maxNoiseError)
	{
		super(new GregorianCalendar(), sender);
		this.bufferSize = bufferSize;
		this.minPercentalBufferContent = minPercentalContent;
		this.actualPercentalBufferContent = actualPercentalContent;
		this.precision = precision;
		this.maxNoiseError = maxNoiseError;
	}
	public IntegratorActualStateIntent(Object sender, boolean running)
	{
		super(new GregorianCalendar(), sender);
		this.running = running;
	}
	
	public void isRunning(boolean value)
	{
		this.running = value;
	}
	public boolean isRunning()
	{
		return this.running;
	}
	public int getBufferSize() {
		return bufferSize;
	}
	public void setBufferSize(int bufferSize) {
		this.bufferSize = bufferSize;
	}
	public double getMinPercentalBufferContent() {
		return minPercentalBufferContent;
	}
	public void setMinPercentalBufferContent(double minPercentalBufferContent) {
		this.minPercentalBufferContent = minPercentalBufferContent;
	}
	public double getActualPercentalBufferContent() {
		double value = Math.round(this.actualPercentalBufferContent * (double) this.precision)/(double)this.precision;
		return value;
	}
	public void setActualPercentalBufferContent(double actualPercentalBufferContent) {
		this.actualPercentalBufferContent = actualPercentalBufferContent;
	}
	public double getPrecision() {
		return precision;
	}
	public void setPrecision(double precision) {
		this.precision = precision;
	}
	public double getMaxNoiseError() {
		return maxNoiseError;
	}
	public void setMaxNoiseError(double maxNoiseError) {
		this.maxNoiseError = maxNoiseError;
	}

	@Override
	public String toString() {
		String retVal = this.getClass().getName() + "\n";
		retVal = retVal + "IsRunning: " + String.valueOf(this.running) + "\n"; 
		retVal = retVal + "BufferSize: " + String.valueOf(this.bufferSize) + "\n"; 
		retVal = retVal + "MinPercentalBufferContent: " + String.valueOf(this.minPercentalBufferContent) +"\n";
		retVal = retVal + "ActualPercentalBufferContent: " + String.valueOf(this.getActualPercentalBufferContent()) +"\n";
		retVal = retVal + "Precision: " + String.valueOf(this.precision) +"\n";
		retVal = retVal + "MaxNoisError: " + String.valueOf(this.maxNoiseError) +"\n";
		return  retVal;
	}
	

}
